package com.iyjhsoc.game.controller;


import com.iyjhsoc.game.domain.VO.PlayerVO;
import com.iyjhsoc.game.domain.entity.PlayerDO;
import com.iyjhsoc.game.domain.request.Request;
import com.iyjhsoc.game.domain.response.Response;
import com.iyjhsoc.game.service.PlayerService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("iyj/player")
public class PlayerController {
    @Resource
    PlayerService playerService;
    @PostMapping("getQueryList")
    public Response getQueryList(Request request){
        return Response.SUCCESS();
    }

    @PostMapping("insertPlayer")
    public Response insertPlayer(PlayerDO request){
        boolean save = playerService.save(request);
        if(save){
            return Response.SUCCESS("保存成功");
        }
        return Response.ERROR("保存失败");
    }

    @PostMapping("updatePlayer")
    public Response updateGame(PlayerDO request){
        boolean b = playerService.updateById(request);
        if(b){
            return Response.SUCCESS("修改成功");
        } else{
            return Response.ERROR("修改失败");
        }
    }
    @PostMapping("queryList")
    public Response queryList(@RequestBody PlayerVO vo){
        Response response = playerService.queryList(vo);
        return response;
    }

    @PostMapping("queryPage")
    public Response queryPage(@RequestBody PlayerVO vo){
        Response response = playerService.queryPage(vo);
        return response;
    }

    @GetMapping("getPlayerById")
    public Response getPlayerById(String id){
        Response playerById = playerService.getPlayerById(id);
        return playerById;
    }

}
